﻿#region Header

/*
    This file is part of nDoctor Light

    NDoctor is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    NDoctor is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with NDoctor.  If not, see <http://www.gnu.org/licenses/>.
*/

#endregion Header

namespace Probel.Ldoc.ViewModels.Dto
{
    using System.Collections.Generic;

    using Probel.Ldoc.Services.Dto;
    using Probel.Ldoc.Services.Services;

    public class RecordCabinetViewModel : BaseViewModel
    {
        #region Fields

        private readonly IPatientService Service;

        #endregion Fields

        #region Constructors

        public RecordCabinetViewModel(RecordCabinetDto cabinet, IErrorService errorService, IPatientService service, bool isAsync)
            : base(errorService, isAsync)
        {
            this.Service = service;
            this.Drawers = this.ToViewModel(cabinet.Drawers);
        }

        #endregion Constructors

        #region Properties

        public IEnumerable<RecordDrawerViewModel> Drawers
        {
            get;
            set;
        }

        #endregion Properties

        #region Methods

        private IEnumerable<RecordDrawerViewModel> ToViewModel(IEnumerable<RecordDrawerDto> drawers)
        {
            var list = new List<RecordDrawerViewModel>();
            foreach (var item in drawers)
            {
                list.Add(new RecordDrawerViewModel(item, this.ErrorService, this.Service, this.IsAsync));
            }
            return list;
        }

        #endregion Methods
    }
}